# -*- coding: UTF-8 -*-
"""
@Project :xlx-fastapi
@File    :admin_role_dao.py
@Author  :xlx-ali
@Date    :2024/06/24 14:20 星期一
"""

from app.dao.models import XlxAdminRole
from .base_dao import getDatabaseSession


class AdminRoleQueryDao(object):
    """用户查询类dao"""

    @classmethod
    def findByid(cls, id: int) -> XlxAdminRole:
        """单条查询示例"""
        with getDatabaseSession() as session:
            query = session.query(XlxAdminRole).filter(XlxAdminRole.id == id)
            result = query.first()
        return result


class AdminRoleOperateDao(object):
    """操作用户相关dao"""

    # @classmethod
    # def updataAdmin(cls, user: XlxAdmin) -> XlxAdmin:
    #     """更新数据"""
    #     with getDatabaseSession() as session:
    #         query = session.query(XlxAdmin).filter(XlxAdmin.id == user.id).first()
    #         query.last_login_time = user.last_login_time
    #         query.last_login_ip = user.last_login_ip,
    #         query.last_login_ipaddress = user.last_login_ipaddress
    #         session.commit()
    #         session.refresh(query)

    #     return query
